﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace FilterPattern
{
    class Program
    {
        static void Main(string[] args)
        {
            List<Person> persons = new List<Person>();

            persons.Add(new Person("Robert", "Male", "Single"));
            persons.Add(new Person("John", "Male", "Married"));
            persons.Add(new Person("Laura", "Female", "Married"));
            persons.Add(new Person("Diana", "Female", "Single"));
            persons.Add(new Person("Mike", "Male", "Single"));
            persons.Add(new Person("Bobby", "Male", "Single"));

            Filter male = new FilterMale();
            Filter female = new FilterFemale();
            Filter single = new FilterSingle();
            Filter singleMale = new AndFilter(single, male);
            Filter singleOrFemale = new OrFilter(single, female);

            Console.WriteLine("Males: ");
            PrintPersons(male.MeetFilter(persons));

            Console.WriteLine("\nFemales: ");
            PrintPersons(female.MeetFilter(persons));

            Console.WriteLine("\nSingle Males: ");
            PrintPersons(singleMale.MeetFilter(persons));

            Console.WriteLine("\nSingle Or Females: ");
            PrintPersons(singleOrFemale.MeetFilter(persons));

            Console.ReadKey();
        }

        public static void PrintPersons(List<Person> persons)
        {
            foreach (var person in persons)
            {
                Console.WriteLine("Person : [ Name : " + person.GetName()
                   + ", Gender : " + person.GetGender()
                   + ", Marital Status : " + person.GetMaritalStatus()
                   + " ]");
            }
        }
    }
}
